# -*- coding: utf-8 -*-
import logging
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

import global_setting

import uuid

def get_uuid_hex():
    u=uuid.uuid4()
    return u.hex
 

"""
ERROR_DEBUG =0
ERROR_INFO  =1
ERROR_WARNING   =2
ERROR_ERROR =3
ERROR_CRITICAL  =4
"""



class RequestHandler(webapp.RequestHandler):
    def render_template(self,template_values,template_name):
        path =  os.path.join(global_setting.base_dir, 'template/%s.html'%template_name)
        #path =  os.path.join(os.path.dirname(__file__), 'portal/template/error.html')
        #self.response.out.write("path:%s"%path)
        self.response.out.write(template.render(path, template_values))
        
    def render_error(self,e):
        e.log()
        template_values =  {
                            "error":e
                            } 
        self.render_template(template_values, 'error')    

class   Thread_Status:
    """
        INIT -> RUN  ->  SYN
          \      |       /
           \     |      /
                BAD
    """
    INIT    ="INIT" #just created
    SYN     ="SYN"  #already readed all the posts
    RUN     ="RUN"  #just try to run and run to read all the post
    BAD     ="BAD"
            
def main():
    pass

if __name__ == "__main__":      
    main()
        

    